module RemarksHelper
  def set_reply_tag_a(remark)
    raw "<a onClick=\"remark_set_reply_position_submit(
        '#{remark.topic_id}','#{remark.id}')\">
        #{I18n.t('model.remark.reply')}</a>"
  end

  def cancel_reply_tag_a(remark)
    raw "<a onClick=\"remark_set_reply_position_submit(
        '#{remark.topic_id}','')\">
        #{I18n.t('model.remark.cancel_reply')}</a>"
    #raw "<a>#{text}</a>"
          #<a id=<%= raw "remark_cancel_reply_#{topic.id}" %> style="display:none"
          #onClick=<%= raw "\"set_reply('#{topic.id}','','')\"" %>>
  end

#      <span id=<%= raw "reply_position_#{topic.id}" %>>
#        <%= remark.parent_remark.position %>
#      </span>
  def remark_reply_tag(remark)
    if remark.parent_remark.nil?
      ''
    else
      raw "<span id=remark_reply_tag_#{remark.topic_id}>
          #{remark_floor_text(remark.parent_remark)}</span>"
    end
  end

  def remark_floor_text(remark)
    #remark.nil? ? '' : (remark.position + 1).to_s + I18n.t('model.remark.position')
    I18n.t('model.remark.position')
  end

  #replaced by remark_really_submit
  def remark_operation_on_topic_tag(remark)
    hidden_field_tag :operation, '',
         id: "remark_operation_on_topic_#{remark.topic_id}" 
  end

  def remark_topic_id_tag(remark)
    hidden_field(:remark, :topic_id , value: remark.topic_id)
  end

  def remark_parent_remark_id_tag(remark)
    hidden_field :remark, :parent_remark_id , value: remark.parent_remark_id
  end

  def remark_remark_type_question_tag(remark)
    hidden_field :remark, :remark_type_question , value: remark.remark_type_question,
        id: "remark_remark_type_question_#{remark.topic_id}"
  end

  def get_remark_type_text(remark)
    if remark.remark_type.nil? || remark.remark_type == ''
      I18n.t('model.remark.type.none')
    else
      I18n.t("model.remark.type.#{remark.remark_type}")
    end
  end
end
